﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Expect.Core.Test
{
    using Expect.Core.BaseClasses;
    using Expect.Core.Test.Fixtures;

    [TestClass]
    public class ObjectFeedTests
    {
        [TestMethod]
        public void ObjectFeed_Success()
        {
            SpecificationDefinition test = new SpecificationDefinition();
            test.Context = new DefaultExecutionContext();
            test.Context.Container = this;
            var obj = new ObjectFeedActor();
            test.Context.Data["my object"] = obj;

            var fixture = test.AddFixture();
            fixture.WithRow("ObjectFeedImpl", "my object");
            fixture.WithRow("my property", "a dummy text");
            fixture.WithRow("my number", "178");

            test.CalculateResult();

            if (!test.IsSuccessful)
            {
                Assert.Fail(test.GetMessageForFailedResult());
            }

            Assert.AreEqual("a dummy text", obj.MyProperty);
            Assert.AreEqual(178.0, obj.MyNumber);
        }

        [TestMethod]
        public void ObjectFeed_ShouldFail()
        {
            SpecificationDefinition test = new SpecificationDefinition();
            test.Context = new DefaultExecutionContext();
            test.Context.Container = this;
            var obj = new ObjectFeedActor();
            test.Context.Data["my object"] = obj;

            var fixture = test.AddFixture();
            fixture.WithRow("ObjectFeedImpl", "my object");
            fixture.WithRow("dummy property", "a dummy text");

            test.CalculateResult();

            if (test.IsSuccessful)
            {
                Assert.Fail("The fixture should not have been resolved");
            }
        }
    }
}
